import mediator = require("index.mediator");
import model = require("index.model");
import viewmodel = require("index.viewmodel");
import common = require("common");
import eventmgr = require("eventmgr");

declare var discoUri: string;

var cxt = { emgr: null, mtr: null, mdl: null, vm: null };

var emgr = new eventmgr.EventMgr();
cxt.emgr = emgr;

var mtr = new mediator.DiscoMediator(discoUri, cxt);
cxt.mtr = mtr;

var mdl = new model.Model(mtr);
cxt.mdl = mdl;

var vm = new viewmodel.ViewModel(mdl, emgr);
cxt.vm = vm;

mdl.kk(new model.KonsenskisteImpl());
mdl.selectTopic(new model.Topic(1), model.TopicRole.Child);
ko.applyBindings(vm);

emgr.kkNeeded({ id: 12, out: mdl.kk() });
emgr.topicNeeded({ id: 1, out: mdl.topic() });

declare var globalVm;
globalVm = vm;